package com.luhuiguo.cms.client.ui;

import com.extjs.gxt.ui.client.widget.HtmlContainer;
import com.extjs.gxt.ui.client.widget.Text;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.luhuiguo.cms.client.GlobalConstants;
import com.luhuiguo.cms.client.GlobalMessages;
import com.luhuiguo.cms.client.GlobalResources;
import com.luhuiguo.cms.client.presenter.HeaderPresenter;
import com.luhuiguo.cms.shared.model.UserModel;

/**
 * 页首视图。
 * 
 * @author LuHuiguo
 * @version $Id: HeaderView.java 160 2010-05-07 15:12:16Z luhuiguo@gmail.com $
 */
@Singleton
public class HeaderView extends HtmlContainer implements HeaderPresenter.Display {

    @SuppressWarnings("unused")
    private GlobalConstants constants;

    @SuppressWarnings("unused")
    private GlobalMessages messages;

    private Text userText;

    @Inject
    public HeaderView(GlobalConstants constants, GlobalMessages messages, GlobalResources resources) {

        super(messages.header());

        this.constants = constants;
        this.messages = messages;
        this.setStateful(false);

        userText = new Text("");
        this.add(userText, "#cms-user");

    }

    @Override
    public Widget asWidget() {
        return this;
    }

    @Override
    public void showCurrentUser(UserModel user) {
        userText.setText(user.getUsername());

    }

}
